home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’93 / Hellcats FlightRecorder / FlightRecorder.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  2.9 KB  |  136 lines  |  [TEXT/KAHL]

  1. //
  2. //    FlightRecorder
  3. //
  4. //    an FKEY that will allow you to make a QuickTime movie of
  5. //    your Leyte Gulf instant replay
  6. //
  7. //  hard coded for FKEY 0
  8. //  creates a PICS file, you need to use Movie Converter to make a 
  9. //  QuickTime movie
  10. //  I started working on a QuickTime version, but did not complete it
  11. //  look for it later on on your favorite net, or send me mail and I'll send it to ya
  12. //
  13. //    Brigham Stevens
  14. //  Apple Computer, Inc.
  15. //  AppleLink:  BRIGHAM
  16. //  e-mail:     brigham@apple.com
  17. //  MacHack 1993
  18. //
  19. #include "FlightRecorder.h"
  20.  
  21. pascal Boolean gneEntryPoint(short mask, EventRecord *evt);
  22. Boolean CurApIsLeyteGulf();
  23.  
  24. main()
  25. {
  26.  
  27.     Handle        code;
  28.     register     storage    *s;
  29.     CWindowPtr    frontWindow;
  30.     
  31.     /* only run if there is a window */
  32.     frontWindow = (CWindowPtr) FrontWindow();
  33.     if(!frontWindow) return;
  34.     
  35.     /* If you are playing the old Hellcats */
  36.     /* THEN UPGRADE!  Leyte Gulf is only about 20 bucks */
  37.     /* but it only works if you have Hellcats */
  38.     if( CurApIsLeyteGulf() ) {
  39.     
  40.         /* Get a handle to us and make it stay */
  41.         code = Get1Resource('FKEY',0);
  42.         DetachResource(code);
  43.         HNoPurge(code);
  44.  
  45.         s->code = code;
  46.         s = GetStoragePtr();
  47.         
  48.         /* init the PICS file and save the first frame */
  49.         StartRecording(s);
  50.         
  51.         /* patch GetNextEvent so we can copy each frame */
  52.         /* inside SaveAFrame if the space bar is held down */
  53.         /* then GNE is unpatched */
  54.         s->gneLink = (long)GetToolTrapAddress(_GetNextEvent);
  55.         SetToolTrapAddress( (long)StripAddress(gneEntryPoint), _GetNextEvent);
  56.  
  57.     }
  58. }
  59.  
  60. Boolean CurApIsLeyteGulf()
  61. /*
  62.     check for leyte gulf.
  63.     compares CurApName with hard coded constants
  64.     protects you from recording other apps accidently
  65.     Get rid of this to record any app if you want.
  66. */
  67. {
  68.     asm {
  69.             move    #0,d0            ; result to false
  70.             movea.l    #0x910,a0        ; curapname
  71.             cmpi.l    #lg1,(a0)+        ; look for _Ley
  72.             bne        @notIt
  73.             cmpi.l    #lg2,(a0)+        ; te G
  74.             bne        @notIt
  75.             cmpi.w    #lg3,(a0)+        ; ul
  76.             bne        @notIt
  77.             cmpi.b    #lg4,(a0)        ; f
  78.             move    #1,d0            ; found it!
  79.         @notIt
  80.             
  81.     }
  82. }
  83.  
  84. // Events.h
  85.  
  86.  
  87.  
  88. pascal Boolean gneEntryPoint(short mask, EventRecord *evt)
  89. {
  90.         
  91.     unsigned char keys[16];
  92.     storage    *s;
  93.     CWindowPtr wp;
  94.     
  95.     
  96.     s = GetStoragePtr();
  97.     wp = (CWindowPtr)FrontWindow();
  98.     
  99.     SaveAFrame(s);
  100.  
  101.     GetKeys((void*)keys);
  102.  
  103.     if(IsPressed(0x31,keys)) {
  104.         CloseResFile(s->ref);
  105.         SetToolTrapAddress( s->gneLink, _GetNextEvent);
  106.         HPurge(s->code);
  107.     }
  108.     
  109.     // if this code passed throught here and called the real thing
  110.     // then you could record the screen of any application
  111.     // but it would be so slow that it just wouldn't be any fun
  112. }
  113.  
  114.  
  115.  
  116.  
  117. /* this is the block of memory used for static storage */
  118.  
  119. storage *GetStoragePtr(void)
  120. {
  121.     asm {
  122.             bsr.s    @skipStorage        ; jump over all the storage space below
  123.             DC.l    0x00                ; this also pushes the address of
  124.             DC.l    0x00                ; the first byte of it on the stack
  125.             DC.l    0x00
  126.             DC.l    0x00
  127.             DC.l    0x00
  128.             DC.l    0x00
  129.             DC.l    0x00
  130.             DC.l    0x00
  131.             DC.l    0x00
  132.             DC.l    0x00
  133.         @skipStorage
  134.             move.l    (sp)+,d0            ; pop the address and return it
  135.     }
  136. }